package planninglanguage.softconditions;

import base.ProxyBot;
import base.WargusGameState;
import base.WargusUnit;

public class AttackedSoftCondition extends SoftCondition {
	int m_unitID;
	long m_initialCycle;
	
	public AttackedSoftCondition(int a_unitID)
	{
		m_unitID = a_unitID;
		m_initialCycle = ProxyBot.getProxyBot().getCurrCycle();
	}
	
	public void reset()
	{
		m_initialCycle = ProxyBot.getProxyBot().getCurrCycle();
	}	
	
	public String toString(int tabs)
	{
		String n = super.toString(tabs);
		n = n + "Unit Id is: " + m_unitID;
		n = n + " initialCycle is: " + m_initialCycle;
		return n;
	}
	public float test(WargusGameState a_gameState)
	{
		WargusUnit u = a_gameState.getUnit(m_unitID);
//		System.out.println("AttackedCondition: test( unitID = " + m_unitID + " initialCycle = " + m_initialCycle + ")");
		
		if (u!=null) {
			System.out.println("AttackedCondition: test, the last attack was in cycle " + u.getLastAttacked());
			if (u.getLastAttacked()>=m_initialCycle) {
				return 1.0f;
			} 
		}
		return 0.0f;
	}
}
